<h1>查询学生信息</h1>
<div id="cont">
	<if condition="$role_id == 2"><!-- 学生和老师显示不同的内容 -->
		<link rel="stylesheet" href="{$Think.const.HOME_CSS}input.css">
		<form action="__SELF__" method="POST" id="iForm">
			<p>
				<label for="">学号</label>
				<input type="text" value="{$info.id}" disabled>
			</p>
			<p>
				<label for="">班级</label>
				<input type="text" value="{$info.class_id|getClassName}" disabled>
			</p>
			<p>
				<label for="">姓名</label>
				<input type="text" value="{$info.name}" disabled>
			</p>
			<p>
				<label for="">性别</label>
				<select name="gender" class="edit" id="" disabled>
					<option value="0" {$info['gender'] == 0 ? 'selected' : ''}>未选择</option>
					<option value="1" {$info['gender'] == 1 ? 'selected' : ''}>男</option>
					<option value="2" {$info['gender'] == 2 ? 'selected' : ''}>女</option>
				</select>
			</p>
			<p>
				<label for="">入学时间</label>
				<input type="text" value="{$info.time}" disabled>
			</p>
			<p>
				<label for="">地址</label>
				<input type="text" name="address" class="edit" value="{$info.address}" disabled>
			</p>
			<p>
				<label for=""></label>
				<a href="javascript:;" id="edit-btn" style="margin-left: 15px;color: #339933;">修改信息</a>
			</p>
		</form>
		<script>
			$(function(){
				$('body').delegate('#edit-btn', 'click', function(){
					$('.edit').attr('disabled', false);
					var html = '<button type="submit">保存</button><a href="javascript:;" id="edit-cancle-btn" style="margin-left: 15px;color: #339933;">取消修改</a>';
					$(this).after(html).remove();
				});
				$('body').delegate('#edit-cancle-btn', 'click', function(){
					$('.edit').attr('disabled', true);
					var html = '<a href="javascript:;" id="edit-btn" style="margin-left: 15px;color: #339933;">修改信息</a>';
					$(this).after(html);
					$(this).siblings('button').remove();
					$(this).remove();
				});
			});
		</script>
	<else /><!-- 以下是教师可查看内容 -->
		<div class="table-head clearfix">
			<div class="wrap left">
				<span>班级：</span>
				<select name="" id="class-select" class="class-select">
					<foreach name="class_info" item="v">
						<option value="{$v.id}" {$v['id'] == $class_id ? 'selected' : ''}>{$v.name}</option>
					</foreach>
				</select>
			</div>
			<a href="{:U('Student/addInfo')}" class="input-btn right">录入信息</a>
		</div>
		<table id="table" class="table">
			<thead>
				<tr>
					<th>学号</th>
					<th>名字</th>
					<th>性别</th>
					<th>班级</th>
					<th>入学时间</th>
					<th>家庭住址</th>
				</tr>
			</thead>
			<tbody>
				<foreach name="info" item="v">
					<tr>
						<td>{$v.id}</td>
						<td>{$v.name}</td>
						<td>
							<if condition="$v.gender == 1">男<elseif condition="$v.gender == 2" />女<else />保密</if>
						</td>
						<td>{$v.class_id|getClassName}</td>
						<td>{$v.time}</td>
						<td>{$v.address}</td>
					</tr>
				</foreach>
			</tbody>
		</table>

		<script>
			$(function(){
				$('#class-select').change(function(){
					window.location.href = "{:U('Student/showList')}" + "?class_id=" + $(this).val();
				});
			});
		</script>
	</if>
</div>